#ifndef OCTREE_H
#define OCTREE_H

#include "octreeNode.h"
#include "object.h"

class Octree{
    public:
        Octree(const Vector3D & = Vector3D(-5, -5, -5), const Vector3D & = Vector3D(5, 5, 5), const Color & = Color(0, 0.1, 0.8, 1));
        Octree(Object *, int);
        ~Octree();

        void draw(bool, bool);
        Object *getObject() const {return object;};
        OctreeNode *getRoot() const {return root;};

        Vector3D getMin() const;
        Vector3D getMax() const;
        double volume() const;
        double area();
        void rotate(int, int, int);

        void setRoot(OctreeNode *);

    private:
        Vector3D min, max;
        bool staticOctree;
        Object *object;
        OctreeNode *root;
        Color color;

        void calculateMinMax();
        void makeTree(int);
        OctreeNode *makeTreeRecursive(int, Object *);
};

#endif
